import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { StudentVo } from '../vo/student-vo';

@Injectable()
export class StudentService {

  constructor(private http:HttpClient) { }
private getAnObjectUrl="http://localhost:81/getAnObject";

getAnObject(){

  return this.http.get(this.getAnObjectUrl).toPromise();
}

private addStudentUrl="http://localhost:81/saveStudentInfo"
addStudentInfo(svo:StudentVo){
  let p={
    "studentid":svo.studentid,
    "xm":svo.xm,
    "sfzh":svo.sfzh,
    "xh":svo.xh
  }
  
  return this.http.post(this.addStudentUrl,p).toPromise();
}

private getStudentListUrl="http://localhost:81/getStudentList"
getStudentList(){
  return this.http.get(this.getStudentListUrl).toPromise();
}

private getSingleStudentByIdUrl="http://localhost:81/getSingleStudentById";
getSingleStudentById(id:string){
  let p={
  "studentid":id
}
return this.http.post(this.getSingleStudentByIdUrl,p).toPromise();
}

private deleteStudentUrl="http://localhost:81/deleteStudent";
deleteStudent(id:string){
  let p={
    "studentid":id
  }
  return this.http.post(this.deleteStudentUrl,p).toPromise();
}
}